import { defineStore } from 'pinia'
import router from '@/router'

export interface UserInfo {}
const useUserStore = defineStore('user', {
  state: () => ({
    token: '',
    userInfo: null as UserInfo | null,
  }),
  actions: {
    setToken(token: string) {
      this.token = token
    },
    setUserInfo(userInfo: UserInfo) {
      this.userInfo = userInfo
    },
    logout() {
      this.token = ''
      this.userInfo = null
      router.push('/Login')
    },
  },
})

export default useUserStore
